Bind input select element to enum in blazor
In this video we will discuss how to bind input select element to enum type in Blazor.
Gender Enum
We want to bind the Gender enum to Input Select element.

- Enum.GetValues()method returns the list of- Enummemebers (i.e Male, Female, and Other).
- Foreachloop creates a select element option for each enum member.
- The built-in InputSelectcomponent supports binding to anenumout of the box.
<InputSelect @bind-Value="Employee.Gender">
    @foreach (var gender in Enum.GetValues(typeof(Gender)))
    {
        <option value="@gender">@gender</option>
    }
</InputSelect>© 2020 Pragimtech. All Rights Reserved.

